import { Effect, ImmerReducer, Reducer, Subscription } from 'umi';

export interface IArticleState {
    cate: Array<string>,
    content: string,
    title: string
}

export interface ArticleModelType {
  namespace: 'article';
  state: IArticleState;
  reducers: {
    changeArticleInfo: ImmerReducer<IArticleState>,
  };
}

const ArticleModel: ArticleModelType = {
  namespace: 'article',
  state: {
    cate: [],
    content: '',
    title: ''
  },
  reducers: {
    // 启用 immer 之后
    changeArticleInfo(state, action) {
        let NewState = JSON.parse(JSON.stringify(state))
        NewState[action.classify] = action.value
        return NewState
    }
  }
};

export default ArticleModel;